<h2>News</h2>
<?php
    $articles_parts = $articles_pager->RenderParts(10);
    $header         = $articles_parts['header'];
    $footer         = $articles_parts['footer'];
    $record_count   = $articles_parts['record_count'];
    $articles       = $articles_parts['grid'];
    if ( $record_count > 0 )
    {
        foreach( $articles as $article )
        {
            $admin_link = '';
            if ( $is_logged_in )
            {
                $admin_link = link_to('Edit',
                                      array('controller'=>'admin/news' ,'action'=>'modify?from_edit=1&id='.$article['id']));
            }
            // split content by more if its there.
            if ( strstr($article['content'],'<!--more-->') !== false)
            {
                $econtent = explode('<!--more-->',$article['content']);
                $more_link = "<br>".link_to("Full Story &raquo;",
                                        array('controller'=>'news' ,
                                              'action'=>'read'.$article['index_name'].'#read_more'));
                $article['content'] = $econtent[0].$more_link;                
            }
            
            // news image
            $news_image = '';
            if ( !empty($article['file_id']) )
            {
                use_helper('admin/files');
                $path         = get_installed_path();
                $path_to_file = public_path_to_file($article['file_id']);
                // you can use w or h to change dimensions, plus all the other options for phpthumb
                $news_image   = "<img src='$path/img.php?src=$path/$path_to_file&h=100' class='news_image' />";
            }
            
            printf("<div class='news_story'>
                        <h3 class='news_story_title'>%s</h3>
                        %s
                        <div class='news_story_meta'>%s %s</div>
                        <div class='news_story_body'>%s</div>
                        <div class='news_story_categories'>%s</div> %s
                    </div>",
                    link_to($article['title'],array('controller'=>'news' ,'action'=>'read/'.$article['index_name'])),    
                    $news_image,                
                    date_format($article['publish_date']),
                    $article['source'],
                    $article['content'],
                    $article['Categories'],
                    $admin_link);
        }
        echo "<p>$footer $header</p>";
    } else {
        echo "<p>No articles.</p>";
    }

?>